class Solution(object):
    def mostVisited(self, n, rounds):
        out = [0] * n
        for i in range(1, len(rounds)):
            last = rounds[i - 1]
            now = rounds[i]
            if i > 1:
                last = (last + 1) % n
            if last <= now:
                for i in range(last, now + 1):
                    out[i - 1] += 1
            else:
                for i in range(last, n + 1):
                    out[i - 1] += 1
                for i in range(1, now + 1):
                    out[i - 1] += 1
        max_value = max(out)
        ans = []
        for i in range(n):
            if out[i] == max_value:
                ans.append(i + 1)
        return ans

